/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.opmviewer.jung;

import edu.uci.ics.jung.visualization.util.VertexShapeFactory;
import java.awt.Color;
import java.awt.Paint;
import java.awt.Shape;
import org.apache.commons.collections15.Transformer;
import org.openprovenance.model.Artifact;

/**
 *
 * @author grzegorz
 */
public class JungOPMArtifact extends Artifact implements JungOPMVertex {

    public JungOPMArtifact(Artifact art) {
        this.art = art;
    }
    private Artifact art;

    public Shape getShape() {

        Transformer<JungOPMVertex, Integer> vertexSize =
                new Transformer<JungOPMVertex, Integer>() {

                    public Integer transform(JungOPMVertex v) {
                        return 50;
                    }
                };
        Transformer<JungOPMVertex, Float> vertexAR =
                new Transformer<JungOPMVertex, Float>() {

                    public Float transform(JungOPMVertex v) {
                        return 1.0f;
                    }
                };
        VertexShapeFactory<JungOPMVertex> vsf =
                new VertexShapeFactory(vertexSize, vertexAR);
        return vsf.getEllipse(this);
    }

    public Paint getPaint() {
        return Color.RED;
    }

    public String getLabel() {
        return art.getId();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof JungOPMVertex)) {
            return false;
        }
        return (getLabel().compareTo(
                ((JungOPMVertex) o).getLabel()) == 0);
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.art != null ? this.art.hashCode() : 0);
        return hash;
    }
}
